<template>
	<div>

		<div class="row">
			<div class="col-xs-12">
				<div class="panel">
					<div class="panel-heading bk-bg-primary">
						<h6><i class="fa fa-edit red"></i>新增公告</h6>
					</div>
					<div class="panel-body bk-bg-white bk-padding-top-30 bk-padding-bottom-20">
						<form class="form-horizontal form-bordered">

							<div class="form-group">
								<label class="col-md-3 control-label">公告标题</label>
								<div class="col-md-9">
									<input type="text" name="text-input" class="form-control" v-model="noticeTitle" placeholder="公告标题">
								</div>
							</div>
							<div class="form-group">
								<label class="col-md-3 control-label">公告内容</label>
								<div class="col-md-9">
									<textarea id="textarea-input" name="textarea-input" rows="6" class="form-control" v-model="noticeContent" placeholder="公告内容"></textarea>
								</div>
							</div>
							<div class="form-group">
								<label class="col-md-3 control-label"></label>
								<div class="col-md-9">
									<input type="button" class="btn btn-primary button-previous" name="previous" @click="noticeAdd" value="提交">
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>

		<lsc-result v-show="noticeMsg.resultMsg" :class="fadeClass">
			{{noticeMsg.resultMsg || '新增成功'}}
		</lsc-result>
	</div>
</template>
<script>

	import LscResult from '../../components/result_msg.vue'
	import {mapGetters} from 'vuex'

	export default{
		name: 'noticeAdd',
		computed: {
			...mapGetters({
				navStatus: 'getNavStatus',
				noticeMsg: 'getResultMsg'
			}),
			popup () {

			}
		},
		data () {
			return {
				noticeTitle: '',    // 标题
				noticeContent: '',  // 内容
				fadeClass: 'fadeInUp',      // 动画类名
				showpopup: false,      // 动画类名
			}
		},
		methods: {
			noticeAdd () {

				let params = {
					title: this.noticeTitle,
					content: this.noticeContent
				}
				this.$store.dispatch('fetchNoticeAdd', params)

			}
		},
		created () {

		},
		mounted () {
			/*setTimeout(() => {
				this.showpopup = true;
			}, 5000);*/
			// 全球
			//	this.$store.dispatch('fetchProductsData', this.classids)

		},
		watch: {
			showpopup(val) {
				console.log(val)
				if (val) {
					setTimeout(() => {
						this.fadeClass = 'fadeOutDown'
						setTimeout(() => {
							this.fadeClass = 'fadeInUp'
							this.showpopup = false
						}, 800);
					}, 2000);
				}
			},
			popup (val) {
				if(!val){
					this.showpopup = true
					this.fadeClass = 'fadeInUp'
				}
			}
		},
		components: {
			LscResult
		}
	}
</script>

<style>

</style>
